<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Vote
 * @copyright  Copyright 2011 KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: item-options.tpl 2011-03-09 01:11:30 idris $
 * @author     Idris
 */
?>
  
<?php if ($this->object->authorization()->isAllowed($this->viewer, 'comment') && method_exists($this->object, 'likes')): ?>
<div class="kowcore-like-button option">
	<?php if (!$this->object->likes()->isLike($this->viewer)): ?>
		<a href="javascript:void(0)" class="kowcore-like" onclick="en4.kowcore.like('<?php echo $this->object->getGuid(); ?>', this)">
			<?php echo $this->translate('Like'); ?>
		</a>
	<?php else: ?>
		<a href="javascript:void(0)" class="kowcore-unlike" onclick="en4.kowcore.unlike('<?php echo $this->object->getGuid(); ?>', this)">
			<?php echo $this->translate('Unlike'); ?>
		</a>
	<?php endif; ?>
</div>
<?php endif; ?>

<?php
$type = $this->object->getType();
switch ($type) {
	case 'user':
		$html = $this->userFriendship($this->object);
		if ($html) {
			echo '<div class="option">'.$this->userFriendship($this->object).'</div>';
		}
		if (!$this->viewer->isSelf($this->object) && $this->viewer->getIdentity()) {
			echo '<div class="option">'.$this->htmlLink($this->url(array('action' => 'compose', 'to' => $this->object->getIdentity()), 'messages_general'), $this->translate('Send Message'), array('class' => 'send_message')).'</div>';
		}
	break;
	case 'event':
    $info = Engine_Api::_()->kowcore()->getEventRSVPLink($this->object);
		if ($info) {
			$route = $info['route'];
			$label = $info['label'];
			$params = $info['params'];
			$icon = $info['icon'];
			$class = $info['class'].' event_rsvp';
			echo '<div class="option">'.$this->htmlLink($this->url($params, $route), $this->translate($label), array('class' => $class)).'</div>';
		}
	break;
	case 'group':
    $info = Engine_Api::_()->kowcore()->getGroupMembershipLink($this->object);
		if ($info) {
			$route = $info['route'];
			$label = $info['label'];
			$params = $info['params'];
			$icon = $info['icon'];
			$class = $info['class'].' group_membership';
			echo '<div class="option">'.$this->htmlLink($this->url($params, $route), $this->translate($label), array('class' => $class)).'</div>';
		}
	break;
	case 'contest':
    $show = (!$this->object->isParticipated($this->viewer)
			&& $this->object->isStarted()
			&& !$this->object->isOwner($this->viewer)
			&& $this->object->authorization()->isAllowed($this->viewer, 'participate'));
    $route = 'contest_general';
    if ($show) {
      echo '<div class="option">'.$this->htmlLink($this->url(array('action' => 'participate', 'id' => $this->object->getIdentity()), 'contest_general'), $this->translate('Participate'), array('class' => 'participate')).'</div>';
		}
	break;
}
?>